from flask import Flask, render_template, url_for, request, session, redirect
app = Flask(__name__)
app.config['SECRET_KEY'] = 'XXXXXXX'
@app.route('/')
def launch():
    return render_template('main.html', username=session.get('username'))

@app.route('/panel')
def panel():
    return render_template('panel.html')

@app.route('/login')
def login():
    return render_template('login.html')

@app.route('/logout', methods=['GET'])
def logout():
    if (session.get('username')):
        session.pop('username')
    return render_template('main.html')

@app.route('/login/check', methods=['POST'])
def check():
    if request.form.get('username') == 'ldk' and request.form.get('password') == '1234':
        session['username'] = request.form.get('username')
        return {'success': True}
    else:
        return {'success': False}

# 非空字符串代表跳转
@app.route('/run', methods=['POST'])
def run():
    print(request.form)
    return ' '

@app.route('/result', methods=['GET'])
def result():
    return render_template('result.html')

if __name__ == '__main__':
    app.run(debug=True, port=8080, threaded=True) # host='0.0.0.0'